<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>xilsem: xsem_npi_example_pl_mb.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">xilsem
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;"
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xsem__npi__example__pl__mb_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xsem_npi_example_pl_mb.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file demonstrates on how to use XilSEM NPI client interface on PL Microblaze to send commands to PLM firmware and read responses from PLM. </p>
<dl class="section note"><dt>Note</dt><dd>The default linker settings places a software stack, heap and data in PL MB memory. For this example to work, any data shared between client running on PL and server running on PMC, should be placed in area which is accessible to both client and server.</dd></dl>
<p>Following is the procedure to provide shared memory region which can be accessed by server</p>
<p>In linker script(lscript.ld) user can add new memory section in source tab as shown below </p>
<pre class="fragment">            .sem_decdata : {
                    KEEP (*(.sem_decdata))
            } &gt; axi_noc_0_C0_DDR_LOW0
</pre><pre>
MODIFICATION HISTORY:</pre><pre>Ver   Who       Date        Changes
</p>
<hr/>
<p>
0.1   gupta   11/16/2022  Initial Creation
0.2   anv     10/18/2023  Added macro to Enable Error Injection Feature
                          usage and Updated Xilsem prints to get
                          Npi status information and
                          Added Test print summary
0.3   gam     01/02/2023  Fixed IPI interrupt ID for PL MB Versal Net,
                          Removed false else condition in main function
                          for XSem_CmdNpiGetStatus API as this is not a
                          valid case for deferred start-up.
</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a6d99b9735fb6389f87f724da74dc1609"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsem__npi__example__pl__mb_8c.html#a6d99b9735fb6389f87f724da74dc1609">INTC_DEVICE_IPI_INT_ID</a>&#160;&#160;&#160;XPAR_AXI_INTC_0_VERSAL_CIPS_0_PSPMC_0_PS_PL_IRQ_LPD_IPI_IPI1_INTR</td></tr>
<tr class="memdesc:a6d99b9735fb6389f87f724da74dc1609"><td class="mdescLeft">&#160;</td><td class="mdescRight">Interrupt Number of IPI whose interrupt output is connected to the input of the Interrupt Controller.  <a href="#a6d99b9735fb6389f87f724da74dc1609">More...</a><br/></td></tr>
<tr class="separator:a6d99b9735fb6389f87f724da74dc1609"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a0d1727d5d5abe0b3a960bc035bc4d45e"><td class="memItemLeft" align="right" valign="top">XStatus&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsem__npi__example__pl__mb_8c.html#a0d1727d5d5abe0b3a960bc035bc4d45e">XSem_ApiCheckScanCount</a> (<a class="el" href="struct_x_sem_npi_status.html">XSemNpiStatus</a> *NpiStatus)</td></tr>
<tr class="separator:a0d1727d5d5abe0b3a960bc035bc4d45e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8eda281f7a0e850ffe2973a997cc8fbd"><td class="memItemLeft" align="right" valign="top">XStatus&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsem__npi__example__pl__mb_8c.html#a8eda281f7a0e850ffe2973a997cc8fbd">XSem_ApiCheckHbtCount</a> (<a class="el" href="struct_x_sem_npi_status.html">XSemNpiStatus</a> *NpiStatus)</td></tr>
<tr class="separator:a8eda281f7a0e850ffe2973a997cc8fbd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad815d14892da5f95a002dea17c44cb4b"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsem__npi__example__pl__mb_8c.html#ad815d14892da5f95a002dea17c44cb4b">XSem_NpiEventRegisterNotifier</a> (u32 Enable)</td></tr>
<tr class="separator:ad815d14892da5f95a002dea17c44cb4b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaea6614590c6c6eedade935ae1c1a26c"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsem__npi__example__pl__mb_8c.html#aaea6614590c6c6eedade935ae1c1a26c">SetUpInterruptSystem</a> (XIntc *XIntcInstancePtr)</td></tr>
<tr class="memdesc:aaea6614590c6c6eedade935ae1c1a26c"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function connects the IPI interrupts to the interrupt controller and to the processor.  <a href="#aaea6614590c6c6eedade935ae1c1a26c">More...</a><br/></td></tr>
<tr class="separator:aaea6614590c6c6eedade935ae1c1a26c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8ada016a202fb27c62bb5cc5aece9b8"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsem__npi__example__pl__mb_8c.html#aa8ada016a202fb27c62bb5cc5aece9b8">IntcAndIpiInit</a> (void)</td></tr>
<tr class="memdesc:aa8ada016a202fb27c62bb5cc5aece9b8"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function initializes Interrupt Controller and IPI drivers.  <a href="#aa8ada016a202fb27c62bb5cc5aece9b8">More...</a><br/></td></tr>
<tr class="separator:aa8ada016a202fb27c62bb5cc5aece9b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsem__npi__example__pl__mb_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">The purpose of this function is to illustrate the usage of client APIs for NPI scan over IPI.  <a href="#a840291bc02cba5474a4cb46a9b9566fe">More...</a><br/></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a6d99b9735fb6389f87f724da74dc1609"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define INTC_DEVICE_IPI_INT_ID&#160;&#160;&#160;XPAR_AXI_INTC_0_VERSAL_CIPS_0_PSPMC_0_PS_PL_IRQ_LPD_IPI_IPI1_INTR</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Interrupt Number of IPI whose interrupt output is connected to the input of the Interrupt Controller. </p>

<p>Referenced by <a class="el" href="xsem__cram__example__pl__mb_8c.html#aaea6614590c6c6eedade935ae1c1a26c">SetUpInterruptSystem()</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="aa8ada016a202fb27c62bb5cc5aece9b8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int IntcAndIpiInit </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function initializes Interrupt Controller and IPI drivers. </p>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS to indicate success, otherwise XST_FAILURE. </dd></dl>
<p>Initialize the interrupt controller driver so that it is ready to use.</p>
<p>Perform a self-test to ensure that the hardware was built correctly.</p>

<p>References <a class="el" href="xsem__cram__example__pl__mb_8c.html#aaea6614590c6c6eedade935ae1c1a26c">SetUpInterruptSystem()</a>.</p>

</div>
</div>
<a class="anchor" id="a840291bc02cba5474a4cb46a9b9566fe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The purpose of this function is to illustrate the usage of client APIs for NPI scan over IPI. </p>
<dl class="section return"><dt>Returns</dt><dd></dd></dl>
<ul>
<li>XST_SUCCESS - on successful execution of injection and detection of error</li>
<li>XST_FAILURE - on failure</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>Npi example always injects error in the golden SHA of the first descriptor. The injected SHA error can be corrected by executing the error injection sequence again. Real SHA errors are uncorrectable. </dd></dl>
<p>Disable cache to get the shared buffer data from physical memory which is updated by PLM in response to NPI commands</p>
<p>Initialize IPI Driver This initialization is required to get XilSEM event notifications from PLM</p>
<p>The following sequence demonstrates how to inject errors in NPI</p>
<ol type="1">
<li>Stop NPI scan</li>
<li>Read current Golden SHA from descriptors</li>
<li>Inject error</li>
<li>Start NPI scan</li>
<li>Read for Golden SHA mismatch error</li>
<li>Read current Golden SHA from descriptors Note: Execute the sequence again to correct the injected error, but the error status will remain till POR. Note: For Error injection feature check enable XILSEM_ERRINJ_ENABLE macro</li>
</ol>

<p>References <a class="el" href="xsem__client__api_8h.html#a7dcab524effe7d228464f765a3010913">CMD_ACK_NPI_ERRINJECT</a>, <a class="el" href="xsem__client__api_8h.html#aa6ca4d0571e27d9a110753dbd7fd1cdb">CMD_ACK_NPI_GET_GLDN_SHA</a>, <a class="el" href="xsem__client__api_8h.html#a2e9dbdbc39535fd7129b9001e1db1d35">CMD_ACK_NPI_STARTSCAN</a>, <a class="el" href="xsem__client__api_8h.html#a5161ee15adc2e003d38492c3ea774a7f">CMD_ACK_NPI_STOPSCAN</a>, <a class="el" href="struct_x_sem___descriptor_data.html#a2d5a9bcef8329ea2bdf6a73e223aab8e">XSem_DescriptorData::DescriptorCount</a>, <a class="el" href="struct_x_sem_npi_status.html#a0b7d87074b8e1445554c051089fb7228">XSemNpiStatus::ErrInfo</a>, <a class="el" href="struct_x_sem_npi_status.html#af831524318353b603e14fda32c75809f">XSemNpiStatus::HbCnt</a>, <a class="el" href="xsem__cram__example__pl__mb_8c.html#aa8ada016a202fb27c62bb5cc5aece9b8">IntcAndIpiInit()</a>, <a class="el" href="xsem__client__api_8h.html#af3fd0512f794e86ac22bce16c7b4a170">MAX_NPI_ERR_INFO_CNT</a>, <a class="el" href="xsem__client__api_8h.html#af9560eda50f4b3e80b3113074fb27707">MAX_NPI_SLV_SKIP_CNT</a>, <a class="el" href="struct_x_sem_ipi_resp.html#a7d7eea2dd43f003a0602eeebaf3ac85d">XSemIpiResp::RespMsg1</a>, <a class="el" href="struct_x_sem_ipi_resp.html#a1502bcdecb5e80f54fd9f283dfeb8a2c">XSemIpiResp::RespMsg2</a>, <a class="el" href="struct_x_sem_npi_status.html#af86519a71bc534fd458933dd18fa46d4">XSemNpiStatus::ScanCnt</a>, <a class="el" href="struct_x_sem_npi_status.html#ad6bb1c2e66f4523d239e18ff685a9ca9">XSemNpiStatus::SlvSkipCnt</a>, <a class="el" href="struct_x_sem_npi_status.html#a00fb9e1d6176efdd76fa98fb28e68234">XSemNpiStatus::Status</a>, <a class="el" href="xsem__npi__example__pl__mb_8c.html#a0d1727d5d5abe0b3a960bc035bc4d45e">XSem_ApiCheckScanCount()</a>, <a class="el" href="group__xsem__client__apis.html#ga90b532fd63cfdad4790f9144aaca2523">XSem_CmdNpiGetGldnSha()</a>, <a class="el" href="group__xsem__client__apis.html#ga81a2507bb54e6b6e8b28399c4196876a">XSem_CmdNpiGetStatus()</a>, <a class="el" href="group__xsem__client__apis.html#gae1747f42d213d24731e0004b1a47e99b">XSem_CmdNpiInjectError()</a>, <a class="el" href="group__xsem__client__apis.html#gac7eac8a55d819df4d84df2c48d95e5d6">XSem_CmdNpiStartScan()</a>, <a class="el" href="group__xsem__client__apis.html#gacabf49b2dbc63f0d9e960b32de5594d6">XSem_CmdNpiStopScan()</a>, and <a class="el" href="xsem__npi__example__pl__mb_8c.html#ad815d14892da5f95a002dea17c44cb4b">XSem_NpiEventRegisterNotifier()</a>.</p>

</div>
</div>
<a class="anchor" id="aaea6614590c6c6eedade935ae1c1a26c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int SetUpInterruptSystem </td>
          <td>(</td>
          <td class="paramtype">XIntc *&#160;</td>
          <td class="paramname"><em>XIntcInstancePtr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function connects the IPI interrupts to the interrupt controller and to the processor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Intc</td><td>instance pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status : Success or Failure </dd></dl>
<p>Connect IPI interrupt handler that will be called when an interrupt for the IPI occurs, the IPI interrupt handler performs the specific interrupt processing for IPI.</p>
<p>Start the interrupt controller such that interrupts are enabled for all devices that cause interrupts.</p>

<p>References <a class="el" href="xsem__npi__example__pl__mb_8c.html#a6d99b9735fb6389f87f724da74dc1609">INTC_DEVICE_IPI_INT_ID</a>.</p>

</div>
</div>
<a class="anchor" id="a8eda281f7a0e850ffe2973a997cc8fbd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">XStatus XSem_ApiCheckHbtCount </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_sem_npi_status.html">XSemNpiStatus</a> *&#160;</td>
          <td class="paramname"><em>NpiStatus</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Small delay to ensure NPI scan progresses before second read. The delay value assumes 100ms as NPI scan interval</p>

<p>References <a class="el" href="struct_x_sem_npi_status.html#af831524318353b603e14fda32c75809f">XSemNpiStatus::HbCnt</a>, and <a class="el" href="group__xsem__client__apis.html#ga81a2507bb54e6b6e8b28399c4196876a">XSem_CmdNpiGetStatus()</a>.</p>

</div>
</div>
<a class="anchor" id="a0d1727d5d5abe0b3a960bc035bc4d45e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">XStatus XSem_ApiCheckScanCount </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct_x_sem_npi_status.html">XSemNpiStatus</a> *&#160;</td>
          <td class="paramname"><em>NpiStatus</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Small delay to ensure NPI scan progresses before second read. The delay value assumes 100ms as NPI scan interval</p>

<p>References <a class="el" href="struct_x_sem_npi_status.html#af86519a71bc534fd458933dd18fa46d4">XSemNpiStatus::ScanCnt</a>, and <a class="el" href="group__xsem__client__apis.html#ga81a2507bb54e6b6e8b28399c4196876a">XSem_CmdNpiGetStatus()</a>.</p>

<p>Referenced by <a class="el" href="xsem__npi__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
<a class="anchor" id="ad815d14892da5f95a002dea17c44cb4b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int XSem_NpiEventRegisterNotifier </td>
          <td>(</td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>Enable</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>In this example all NPI events are enabled If you want to enable particular event set the Event member in Notifier structure with corresponding event.</p>

<p>References <a class="el" href="struct_x_sem___notifier.html#a14fb3416755928d53ced15f1f52f333d">XSem_Notifier::Flag</a>, and <a class="el" href="group__xsem__client__apis.html#gabb35fc319871e2265620aae73c7c5791">XSem_RegisterEvent()</a>.</p>

<p>Referenced by <a class="el" href="xsem__npi__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
